package com.bys.admin.system.controller;


import com.bys.admin.system.entity.SysMenu;
import com.bys.response.R;
import com.bys.admin.system.service.ISysMenuService;
import com.bys.admin.system.vo.SysMenuVo;


import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author bys
 * @since 2023-06-26
 */
@Tag(name = "菜单接口")
@RestController
@RequestMapping("/system/sys-menu")
public class SysMenuController {
    @Resource
    private ISysMenuService sysMenuService;
    @Operation(summary = "获取菜单")
    @GetMapping("/simple-list")
    public R<List<SysMenuVo>> simpleList(){
        List<SysMenuVo> userMenuList = sysMenuService.getUserMenuList();
        return R.success(sysMenuService.getUserMenuList());
    }
    @Operation(summary = "获取用户的菜单")
    @GetMapping("/getUserMenuList")
    public R< List<SysMenuVo>> getUserMenuList(){
        List<SysMenuVo> data = sysMenuService.getUserMenuList();
        return R.success(data);
    }
    @Operation(summary="保存菜单")
    @PostMapping("/save")
    public R<Boolean> saveMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.save(sysMenu);
        return R.success(Boolean.TRUE);
    }

    @Operation(summary="修改菜单")
    @PutMapping("/update")
    public R<Boolean> updateMenu(@RequestBody SysMenu sysMenu){
        sysMenuService.updateById(sysMenu);
        return R.success(Boolean.TRUE);
    }
    @Operation(summary="删除菜单")
    @DeleteMapping("/delete/{menuId}")
    public R<Boolean> deleteMenu(@PathVariable Long menuId){
        sysMenuService.removeById(menuId);
        return R.success(Boolean.TRUE);
    }

}
